package org.wattdepot.cli.command;

import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the listSummary method with various inputs for correct outputs.
 * 
 * @author Alex Kan and Kelvin Green
 * @version 2.0
 */
public class TestWattDepotListSummary {

  WattDepotCommand commandInstance;
  String[] commandArray;
  String userInput;

  /**
   * Test WattDepotListSummary command for 2 correct outputs and errors on 2 inputs. 
   * Test (correct) summary SIM_KAHE_1: carbonIntensity : 1744 
   * Test (correct) summary SIM_KAHE_7: Total data points: 6528
   * Test (error) summary SIM_WAIAU_7_: The specified source was not found. 
   * Test (error) summary chicken 4: Correct command is summary {source}
   */
  @Test
  public void testListSummary() {
    WattDepotCommand.connect("http://server.wattdepot.org:8182/wattdepot/");
    commandInstance = new WattDepotListSummaryCommand();
    userInput = "summary SIM_KAHE_1";
    commandArray = userInput.split(" ");
    assertTrue("Check for SIM_KAHE_1", commandInstance.doCommand(commandArray).contains(
        "carbonIntensity : 1744"));

    userInput = "summary SIM_KAHE_7";
    commandArray = userInput.split(" ");
    assertTrue("Check for SIM_KAHE_7", commandInstance.doCommand(commandArray).contains(
        "Total data points: 6528"));

    userInput = "summary SIM_WAIAU_7_";
    commandArray = userInput.split(" ");
    assertTrue("Check for error", commandInstance.doCommand(commandArray).contains(
        "The specified source was not found."));

    userInput = "summary chicken 4";
    commandArray = userInput.split(" ");
    assertTrue("Check for error", commandInstance.doCommand(commandArray).contains(
        "Correct command is summary {source}"));

  }

}
